﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using Microsoft.Practices.Unity;
using ScrumTable.BL.DM.DataManagement;
using ScrumTable.Common.FileSystem;
using ScrumTable.DL.Data.Common;
using ScrumTable.UI.View.WinTouch.Win32Interopt;
using ScrumTable.UI.ViewModel;
using ScrumTable.UI.ViewModel.Controller;
using ScrumTable.UI.ViewModel.Data;
using ScrumTable.UI.ViewModel.Tools;

namespace ScrumTable.UI.View.WinTouch.UserControls.Tool
{
	/// <summary>
	/// Interaction logic for SearchScreen.xaml
	/// </summary>
	public partial class ReportSelector
    {

        #region Decleration
        //--------------------------------------------------------------------
        // Decleration
        //--------------------------------------------------------------------
	    
        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------
   


        [Dependency]
        public ViewModelReportSelector Model
        {
            set
            {
                  DataContext = value;
            }
            get
            {
                return (ViewModelReportSelector)DataContext;
            }

        }


      
        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        public ReportSelector()
        {
            InitializeComponent();
            Loaded += OnLoaded;
        }

       


        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

       

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        void OnLoaded(object sender, RoutedEventArgs e)
        {
            Loaded -= OnLoaded;
            Browser.Width = 400;
            Browser.Height = 400;
            new BrowserRemotingProxy(Browser);
            
        }


        private void OnReportBorderSizeChanged(object sender, SizeChangedEventArgs e)
        {
            Renderer.Width = e.NewSize.Width;
            Renderer.Height = e.NewSize.Height;
        }

        private void OnSurfaceListBoxSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            var url = ReportList.SelectedItem as Uri;
            if (url != null)
            {
                if (url.IsAbsoluteUri)
                {
                    Browser.Navigate(url);
                }
                else
                {
                    Browser.Navigate(DataFolderUtil.GetDataFile(url.ToString()));
                }
            }
            else
            {
                Browser.Navigate("about:blank");
            }
        }


        #endregion

    }
}